import request from '@/utils/request'
// 获取目录信息列表
export function getCataInfo(params) {
  return request({
    url: '/subject/directory',
    method: 'GET',
    params
  })
}
// 切换开关状态
export function switchState(data) {
  return request({
    url: `/subject/directory/${data.id}`,
    method: 'PUT',
    data
  })
}
// 添加目录
export function addCataInfo(data) {
  return request({
    url: '/subject/directory',
    method: 'POST',
    data
  })
}
// 归属学科下拉框渲染
export function getCataTree() {
  return request({
    url: '/subject/tree',
    method: 'get'
  })
}
// 删除目录
export function delCataInfo(id) {
  return request({
    url: `/subject/directory/${id}`,
    method: 'DELETE'
  })
}
// 获取单个目录的信息
export function getSingleCata(id) {
  return request({
    url: `/subject/directory/${id}`,
    method: 'GET'
  })
}
// /subject/subject/+data.id
// 获取单个目录的信息
export function editSingleCata(data) {
  return request({
    url: `/subject/directory/${data.id}`,
    method: 'PUT',
    data
  })
}

 // 获取学科信息数据
 export const getsubjectitem = params => {
   return request({
     url: `/subject/subject/`,
     method: 'GET',
     params
   })
 }


  // 切换按钮数据
  export const toggleButton = data => {
    return request({
      url: `/subject/subject/${data.id}`,
      method: 'put',
      data
    })
  }

//删除学科信息
export const delsubject = id =>{
  return request({
    url:`/subject/subject/${id}`,
    method:'DELETE'
  })
}

//添加学科信息
export const addsubject = data =>{
  return request({
    url:'/subject/subject',
    method:'post',
    data
  })
}

//]编辑回显
export const editsubject = id =>{
  return request({
    url:`/subject/subject/${id}`,
    method:'get',
  })
}
//编辑
export const editsubjectitem = data =>{
  return request({
    url:`/subject/subject/${data.id}`,
    method:'put',
    data
  })
}

//上传头像
export const addphone = data =>{
  return request({
    url:`/index/upload/?mode=single&type=image`,
    method:'POST',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
